package com.cqie.hospitalescort.DTO;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;

@Data
@NoArgsConstructor
public class AuthUser implements UserDetails {

    private Long id;

    private String openid;

    private Date createTime;

    private Date updateTime;

    private Integer role;

    private String nickname;

    private Integer gender;

    private String avatarurl;

    private String telnum;

    //管理员
    private String username;

    private String password;

    //陪诊员
    //陪诊人真实姓名
    private String name;

    //性别（0为女，1为男）
    private Integer sex;

    //年龄（出生日期）
    private LocalDate age;

    //联系电话
    private String phone;

    //身份证号
    private String identityCard;

    //详细地址
    private String addressInfo;

    //描述
    private String description;

    //陪诊员福利积分
    private Long score;

    //隶属于的医院id
    private Long hospitalId;

    //陪诊员个性化图片
    private String individuationPicture;

    //评价得分
    private BigDecimal accessScore;

    //状态(1-空闲，2-陪诊中，3-同时间已被预约)
    private Integer escortStatus;

    // token令牌
    private String token;

    private Set<GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        if (Arrays.asList(1, 2).contains(this.role)) {

        }
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
